package com.threegroup.admin.controller;

import com.github.pagehelper.PageInfo;
import com.threegroup.admin.entity.CategoryEntity;
import com.threegroup.admin.service.CategoryService;
import com.threegroup.common.dto.CategoryDTO;
import com.threegroup.common.utils.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/takeout/category")
public class CategoryController {

    @Resource
    private CategoryService categoryService;


    @GetMapping("list")
    public Result<List<CategoryEntity>> getList(){
        Result<List<CategoryEntity>> listResult = categoryService.queryList();
        return  listResult;
    }
    @GetMapping("page")
    public Result<PageInfo<CategoryDTO>> getPage(Integer limit, Integer page, String order, String orderField,String id){

        Result<PageInfo<CategoryDTO>> pageInfoResult= categoryService.queryPage(limit,page,order,orderField,id);
        return  pageInfoResult;
    }
}
